//
   Created by wanthering on 2017/8/16.
html
    head
        mata(name='shareId' content= id)
        mata(name='shareDesc' content= desc)
        mata(name='shareTitle' content= title)
        mata(name='faceUrl' content= faceUrl)
        meta(http-equiv="Content-Type" content="text/html; charset=utf-8")
        meta(name="viewport" content="initial-scale=1,maximum-scale=1,user-scalable=0")
        meta(name="apple-mobile-web-app-status-bar-style" content="black")
        meta(name="apple-mobile-web-app-capable" content="yes")
        meta(content="yes" name="apple-touch-fullscreen")
        meta(name="format-detection" content="telephone=no, email=no")
        title= title
        link(rel="stylesheet" href="/stylesheets/zy.media.css")
        link(rel="stylesheet" href="/stylesheets/detail.css")
    body
        .index_center
            .index_width
                .maincontent_top
                    img(src= faceUrl)
                .zy_media
                    audio(data-config='' src= url)
                if(info && info.trim() !='')
                    .info_box
                        .info_title
                            .info_about 专栏简介
                            .info_booking 9212人正在群内收听
                        .clearfix
                        p.info_content= info
                if(lesson)
                    .lessonWrap
                        .lessonTitle
                            span.t
                            span.h 听课之后，立即做习题巩固效果更佳！
                        a(href='/homework/'+lesson)
                            .lessonBody 点击进入课后习题
                            .lessonDesc ⏏ 多花2分钟，牢牢掌握一节课
                            .lessonExtra 每学一课 领取0.88~12.88元奖学金
                                p.more （可提现到银行卡）
                .midcontent
                    a(href="../qrcode/"+id)
                        .qunName= "『"+ qun + "』"
                        if(admin&& admin!='')
                            .weixinName 如果无法入群，请加群主微信
                                span.qunzhu= admin
                        img(src="/images/qun-bg-01.jpg")

    script(src="/javascripts/flexible.debug.js")
    script(src="/javascripts/flexible_css.debug.js")
    script(src="/javascripts/jquery-1.11.3.min.js")
    script(src="/javascripts/zyy.media.js")
    script(src="https://res.wx.qq.com/open/js/jweixin-1.0.0.js")
    script(type='text/javascript').
      var shareDesc = $('mata[name=shareDesc]').attr('content')
      var shareTitle = $('mata[name=sharetitle]').attr('content')
      var shareItemUrl = $('mata[name=faceUrl]').attr('content') + '-item'
      var shareId = $('mata[name=shareId]').attr('content')
      zymedia('audio');

      var info = $('.info_content').html()
      if(info && info.trim()!=''){
        info = info.replace(/\n/g, '<br/>')
        console.log(info)
        $('.info_content').html(info)
      }

      $('.info_booking').html(parseInt(500+ 6573*Math.random())+'人正在群内收听')

      var APPID = 'wx92f602d76b0c05bc';
      $.ajax({
        type: 'post',
        url: 'https://www.enjoyshadow.com:10333/signature',
        data: {'url': window.location.href},
        dataType: 'json',
        success: function (d) {
          console.log(d);
          wx.config({
            debug: false, // 开启调试模式,调用的所有api的返回值会在客户端alert出来，若要查看传入的参数，可以在pc端打开，参数信息会通过log打出，仅在pc端时才会打印。
            appId: APPID, // 必填，公众号的唯一标识
            timestamp: d.params.timestamp, // 必填，生成签名的时间戳
            nonceStr: d.params.noncestr, // 必填，生成签名的随机串
            signature: d.params.signature,// 必填，签名，见附录1
            jsApiList: ['onMenuShareTimeline',
              'onMenuShareAppMessage'] // 必填，需要使用的JS接口列表，所有JS接口列表见附录2
          });

          wx.ready(function () {
            wx.onMenuShareTimeline({
              title: shareTitle, // 分享标题
              link: "http://audio.enjoyshadow.com/audios/"+shareId, // 分享链接
              imgUrl: shareItemUrl // 分享图标
            });

            wx.onMenuShareAppMessage({
              title: shareTitle, // 分享标题
              link: "http://audio.enjoyshadow.com/audios/"+shareId, // 分享链接
              desc: shareDesc, // 分享描述
              imgUrl: shareItemUrl // 分享图标
            });
          });
        }
      })